@include('backstage/public/_header')

    <div class="result_wrap">
        <form id="form_data" method="post">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <table class="add_tab">
                <tbody>
                <tr>
                    <th width="120"><i class="require">*</i>原密碼：</th>
                    <td>
                        <input type="password" name="pass_old"> <span>請輸入原始密碼</span>
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>新密碼：</th>
                    <td>
                        <input type="password" name="pass_new"> <span>建議使用字母、數字和符號兩種及以上的組合，6-20個字符</span>
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>確認密碼：</th>
                    <td>
                        <input type="password" name="pass_repeat"><span>再次確認密碼，確保兩次輸入密碼相同</span>
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="button" value="提交" id="btnSub" onclick="onSubmit();">
                        <input type="button" class="back" onclick="history.go(-1)" value="返回">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
        <div class="tips">
            <h3>修改密碼說明</h3>
            <p>1、如不修改則留空</p>
            <p>2、點擊提交 -&gt; 修改管理員密碼，返回-&gt; 可以回到上壹層頁面</p>
        </div>
    </div>
    <script type="text/javascript">
        var vfTime = 2;
        var timer=null;
        function setTime(){
            vfTime --;
            if(vfTime<=0){
                vfTime = 0;
                clearInterval(timer);
            }
        }
        function onSubmit(){
            var pass_old=$(":input[name='pass_old']").val();
            var pass_new=$(":input[name='pass_new']").val();
            if (vfTime!=0 && timer!=null){
                layer.msg('操作過於頻繁', {icon: 7,anim: 6});
                // setTimeout(function(){$("#chiContent").focus();}, 1500);
                return false;
            }
            if (pass_old==''){
                layer.msg('原密碼不能為空', {icon: 5,anim: 6});
                setTimeout(function(){$(":input[name='pass_old']").focus();}, 0);
                return false;
            }
            if (pass_new=='') {
                layer.msg('請輸入密碼！', {icon: 5,anim: 6});
                setTimeout(function(){$(":input[name='pass_new']").focus();}, 0);
                return false;
            }
            var form = new FormData(document.getElementById("form_data"));
            $.ajax({
                url:"/backstage/admin/doedit_pass",
                type:"post",
                data:form,
                processData:false,
                contentType:false,
                dataType : "json",
                success:function(data){
                    if(data.status==1){
                        layer.msg(data.message, {icon: 6});
                        setTimeout(function(){
                            window.location.href=data.jumpUrl;
                        },2000);
                    }else if(data.status==-1){
                        layer.alert(data.message, {icon: 2,anim:6});
                    }else{
                        layer.msg(data.message, {icon: 5});
                    }
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                    
                },
                error:function(e){
                    layer.msg(e, {icon: 5,anim: 6});
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                }
            });
        }
    </script>
@include('backstage/public/_footer')